home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_qt3.idb / usr / freeware / Qt / tutorial / t13 / cannon.h.z / cannon.h
Encoding:
C/C++ Source or Header  |  2002-04-08  |  1.3 KB  |  72 lines

  1. /****************************************************************
  2. **
  3. ** Definition of CannonField class, Qt tutorial 13
  4. **
  5. ****************************************************************/
  6.  
  7. #ifndef CANNON_H
  8. #define CANNON_H
  9.  
  10. class QTimer;
  11.  
  12.  
  13. #include <qwidget.h>
  14.  
  15.  
  16. class CannonField : public QWidget
  17. {
  18.     Q_OBJECT
  19. public:
  20.     CannonField( QWidget *parent=0, const char *name=0 );
  21.  
  22.     int   angle() const { return ang; }
  23.     int   force() const { return f; }
  24.     bool  gameOver() const { return gameEnded; }
  25.     bool  isShooting() const;
  26.     QSizePolicy sizePolicy() const;
  27.  
  28. public slots:
  29.     void  setAngle( int degrees );
  30.     void  setForce( int newton );
  31.     void  shoot();
  32.     void  newTarget();
  33.     void  setGameOver();
  34.     void  restartGame();
  35.  
  36. private slots:
  37.     void  moveShot();
  38.  
  39. signals:
  40.     void  hit();
  41.     void  missed();
  42.     void  angleChanged( int );
  43.     void  forceChanged( int );
  44.     void  canShoot( bool );
  45.  
  46. protected:
  47.     void  paintEvent( QPaintEvent * );
  48.  
  49. private:
  50.     void  paintShot( QPainter * );
  51.     void  paintTarget( QPainter * );
  52.     void  paintCannon( QPainter * );
  53.     QRect cannonRect() const;
  54.     QRect shotRect() const;
  55.     QRect targetRect() const;
  56.  
  57.     int ang;
  58.     int f;
  59.  
  60.     int timerCount;
  61.     QTimer * autoShootTimer;
  62.     float shoot_ang;
  63.     float shoot_f;
  64.  
  65.     QPoint target;
  66.  
  67.     bool gameEnded;
  68. };
  69.  
  70.  
  71. #endif // CANNON_H
  72.